import { post, get } from "utils/fetch";

// 获取表单列表数据
export const getListData = (params) => {
  return post("/flow-platform/form/list", params, { messageType: "close" });
};

// 创建表单
// export const addForm = ({ description, key, name, tenantId }) => {
export const addForm = (data) => {
  return post(
    "/flow-platform/form/create",
    // { description, key, name, tenantId },
    data,
    { messageType: "close" },
  );
};

// 复制表单
// export const copyForm = ({ description, key, name, originFormId, tenantId }) => {
export const copyForm = (data) => {
  return post(
    "/flow-platform/form/copy",
    // { originFormId, description, key, name, tenantId },
    data,
    { messageType: "close" },
  );
};

// 删除表单
export const delForm = ({ formId }) => {
  return post(
    "/flow-platform/form/delete",
    { formId },
    { messageType: "close" },
  );
};

// 部署表单
export const publishForm = ({ formId }) => {
  return post(
    "/flow-platform/form/deploy",
    { formId },
    { messageType: "close" },
  );
};

// 停用表单
export const stopForm = ({ formId }) => {
  return post(
    "/flow-platform/form/stop",
    { formId },
    { messageType: "close" },
  );
};
// 预览时加载外部数据源数据
export const preRequestOuterData = (data) => {
  return post(`/flow-platform/form/preRequestOuterData`, data, {
    messageType: "close",
  });
};

// 编辑状态
export const updateStatus = (data) => {
  return post(`/flow-platform/form/updateStatus`, data, { messageType: "close" });
};

// 解析外置表单信息
export const getExternalFormInfo = (params) => {
  return post("/flow-platform/form/analyzeExternalFormInfo", params, { messageType: "close" });
};

// 判断内置外置表单
export const isExternalForm = (params) => {
  return post("/flow-platform/form/isExternalForm", params, { messageType: "close" });
};

// 获取外置表单详情
export const getExternalFormDetail = (params) => {
  return get("/flow-platform/form/externalDetail", params, { messageType: "close" });
};

// 查看表单解析内容
export const viewExternalFormInfo = (params) => {
  return post("/flow-platform/form/viewExternalFormInfo", params, { messageType: "close" });
};
// 查看表单解析内容
export const FormSetupInfo = (params) => {
  return get("/flow-platform/form/formFieldList", params, { messageType: "close" });
};